<template>
  <van-nav-bar
      fixed
      title="我发布的商品列表"
      left-text="返回"
      right-text="+发布"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
  />
  <van-divider></van-divider>
  <van-divider></van-divider>
  <div v-for="item in list" :key="item">
    <van-swipe-cell>
      <van-card
          num="1"
          :price="item.price"
          :title="item.name"
          :thumb="'http://local.bs.com/storage/'+item.image"
          origin-price="10.00"
      />
      <template #right>
        <van-button square text="删除" type="danger" class="delete-button" />
      </template>
    </van-swipe-cell>
  </div>
  <van-pagination v-model="currentPage" :total-items="total" :items-per-page="15" @change="pageClick"/>
  <van-divider></van-divider>
</template>

<script>

import {mygoods} from "@/api/goods";

export default {
  name: "MyGoods",
  data(){
    return {
      list:{},
      currentPage:1,
      total:0,
    }
  },
  created() {
    mygoods(1).then((res)=>{
      this.list = res.data.data
      this.total = res.data.total
    })
  },
  methods:{
    onClickLeft() {
      history.back()
    },
    pageClick(){

    },
    onClickRight(){
      this.$router.push('/publish')
    }
  }
}
</script>

<style scoped>
.delete-button {
  height: 100%;
}
</style>
